home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / drchk031.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-04-28  |  19KB  |  574 lines

  1. /* installation and INI setup */
  2. call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  3. call SysLoadFuncs
  4. call RxFuncAdd 'VInit','VRexx','VInit'
  5.  
  6. arg par1
  7. if par1='/?' | par1='?' then signal usage
  8. if translate(par1)='/I' then do
  9.     inionly=1
  10.     signal inimake
  11. end
  12.  
  13. if translate(par1)='/O' then do
  14.     objonly=1
  15.     signal objmake
  16. end
  17.  
  18. CurrDir=directory()
  19. do until allok=1
  20.     call SysCls
  21.     call SysCurPos 12,0
  22.     say "Which directory do you wish to install DriveCheck to?"
  23.     call charout ," : "
  24.     parse pull instdir
  25.     if directory(instdir)='' then do until valid=1
  26.         call SysCls
  27.         if valid=0 then do
  28.             call SysCurPos 10,0
  29.             say "Please answer with Y or N."
  30.         end
  31.         call SysCurPos 10,0
  32.         call charout ,"Directory not found.  OK to create? (Y/N) :"
  33.         reply=SysGetKey('echo')
  34.         if translate(reply)\='Y' & translate(reply)\='N' then valid=0
  35.         else do
  36.             valid=1
  37.             if translate(reply)='Y' then do
  38.                 rc=SysMkDir(instdir)
  39.                 if rc\=0 then do
  40.                     allok=0
  41.                     call SysCls
  42.                     call SysCurPos 12,0
  43.                     say "Invalid directory name."
  44.                     say ""
  45.                     say "Press any key to continue..."
  46.                     junk=SysGetKey('noecho')
  47.                 end
  48.                 else allok=1
  49.             end
  50.             else allok=0
  51.         end        
  52.     end    
  53.     else do until confirm=1
  54.         call SysCls
  55.         if confirm=0 then do
  56.             call SysCurPos 10,0    
  57.             say "Please answer with either Y or N."
  58.         end
  59.         call SysCurPos 12,0
  60.         call charout ,"Directory already exists, OK to continue? (Y/N) :"
  61.         ans=SysGetKey('echo')
  62.         if translate(ans)\='Y' & translate(ans)\='N' then confirm=0        
  63.         else do
  64.             confirm=1
  65.             if translate(ans)='Y' then allok=1
  66.             else allok=0
  67.         end
  68.     end
  69. end
  70. call directory CurrDir
  71. '*@copy drivechk.cmd '||instdir||' > nul'
  72. '*@copy readme.txt '||instdir||' > nul'
  73. '*@copy drivechk.ico '||instdir||' > nul'
  74. '*@copy install.cmd '||instdir||' > nul'
  75. call directory instdir
  76.  
  77. inimake:
  78.  
  79. if inionly=1 then do
  80.     call SysCls
  81.     call SysCurPos 12,0
  82.     say "Please enter the directory where DriveCheck is located."
  83.     call charout ,': '
  84.     pull instdir
  85.     if directory(instdir)='' then do
  86.         say ""
  87.         say "Directory not found."
  88.         exit
  89.     end
  90.     else call directory instdir
  91. end
  92. call SysCls
  93. call SysCurPos 12,0
  94. say "We will now create an initialization file that will determine"
  95. say "the default behavior of the visual portion of DriveCheck."
  96. say ""
  97. say "Press Q to skip this part or any other key to continue..."
  98. ch=SysGetKey('noecho')
  99. if translate(ch)='Q' then skipini=1
  100. else skipini=0
  101. if skipini=0 then do
  102.  
  103.     crlf='0a0d'x
  104.     rtable=crlf                             ||,
  105.            '         1) 640x480'crlf        ||,
  106.            '         2) 800x600'crlf        ||,
  107.            '         3) 1024x768'crlf       ||,
  108.            '         4) 1280x1024'crlf      ||,
  109.            '         5) 1600x1200'crlf      ||,
  110.            crlf                             ||,
  111.            'Your choice? :'
  112.     rstring="Please select a number corresponding to a resolution on the"crlf,
  113.             "list.  If your resolution isn't listed, pick the closest one."
  114.     do until rok=1
  115.         call SysCls
  116.         if rok=0 then do
  117.             call SysCurPos 3,0
  118.             say "Select the screen resolution your desktop is set to:"
  119.             call charout ,rstring
  120.         end
  121.         call SysCurPos 6,0
  122.         call charout ,rtable
  123.         ans=SysGetKey('echo')
  124.         if datatype(ans)\='NUM' then rok=0
  125.         else if datatype(ans,'W')\=1 then rok=0
  126.         else if ans<1 | ans>5 then rok=0
  127.         else do
  128.             rok=1
  129.             ScrRes=ResID(ans)
  130.         end
  131.     end
  132.     cstring='Please select a color-corresponded number from the list.'    
  133.     table=crlf                                           ||,
  134.           '     1) Black                 5) Blue'crlf    ||,          
  135.           '     2) White                 6) Cyan'crlf    ||,
  136.           '     3) Red                   7) Yellow'crlf  ||,
  137.           '     4) Green                 8) Pink'crlf    ||,
  138.           crlf                                           ||,
  139.           'Your choice? :'
  140.     
  141.     do until mok=1
  142.         call SysCls
  143.         if mok=0 then do
  144.             call SysCurPos 4,0
  145.             say cstring
  146.         end
  147.         call SysCurPos 6,0
  148.         say "Choose the main window background color from the list,"||crlf||,
  149.             "or press S to skip this choice and use the default:"
  150.         call charout ,table
  151.         ans=SysGetKey('echo')
  152.         if translate(ans)='S' then do
  153.             MainColor='WHITE'
  154.             mok=1
  155.         end
  156.         else if datatype(ans)\='NUM' then mok=0
  157.         else if datatype(ans,'W')\=1 then mok=0
  158.         else if ans<1 | ans>8 then mok=0
  159.         else do
  160.             mok=1
  161.             MainColor=ColorID(ans)
  162.         end    
  163.     end    
  164.     mok=''
  165.     do until mok=1
  166.         call SysCls
  167.         if mok=0 then do
  168.             call SysCurPos 4,0
  169.             say cstring
  170.         end
  171.         call SysCurPos 6,0
  172.         say "Choose the main window text color from the list,"||crlf||,
  173.             "or press S to skip this choice and use the default:"
  174.         call charout ,table
  175.         ans=SysGetKey('echo')
  176.         if translate(ans)='S' then do
  177.             MainTextColor='BLACK'
  178.             mok=1
  179.         end
  180.         else if datatype(ans)\='NUM' then mok=0
  181.         else if datatype(ans,'W')\=1 then mok=0
  182.         else if ans<1 | ans>8 then mok=0
  183.         else do
  184.             mok=1
  185.             MainTextColor=ColorID(ans)
  186.             if MainTextColor=MainColor then do
  187.                 say crlf    
  188.                 say "Note:  You have chosen the same color for both the"
  189.                 say "foreground and background of the Main window.  You"
  190.                 say "won't be able to see a damn thing unless you change it."
  191.                 say ""
  192.                 say "Press any key to continue..."
  193.                 junk=SysGetKey('noecho')
  194.             end    
  195.         end
  196.     end
  197.     do until dok=1
  198.         call SysCls
  199.         if dok=0 then do
  200.             call SysCurPos 4,0
  201.             say cstring
  202.         end
  203.         call SysCurPos 6,0
  204.         say "Choose the directory window background color from the list,"||crlf||,
  205.             "or press S to skip this choice and use the default:"
  206.         call charout ,table
  207.         ans=SysGetKey('echo')
  208.         if translate(ans)='S' then do
  209.             DirColor='CYAN'
  210.             dok=1
  211.         end
  212.         else if datatype(ans)\='NUM' then dok=0
  213.         else if datatype(ans,'W')\=1 then dok=0
  214.         else if ans<1 | ans>8 then dok=0
  215.         else do
  216.             dok=1
  217.             DirColor=ColorID(ans)
  218.         end
  219.     end    
  220.     dok=''
  221.     do until dok=1
  222.         call SysCls
  223.         if dok=0 then do
  224.             call SysCurPos 4,0
  225.             say cstring
  226.         end
  227.         call SysCurPos 6,0
  228.         say "Choose the directory window text color from the list,"||crlf||,
  229.             "or press S to skip this choice and use the default:"
  230.         call charout ,table
  231.         ans=SysGetKey('echo')
  232.         if translate(ans)='S' then do
  233.             DirTextColor='BLACK'
  234.             dok=1
  235.         end
  236.         else if datatype(ans)\='NUM' then dok=0
  237.         else if datatype(ans,'W')\=1 then dok=0
  238.         else if ans<1 | ans>8 then dok=0
  239.         else do
  240.             dok=1
  241.             DirTextColor=ColorID(ans)
  242.             if DirTextColor=DirColor then do
  243.                 say crlf    
  244.                 say "Note:  You have chosen the same color for both the"
  245.                 say "foreground and background of the Directory window.  You"
  246.                 say "won't be able to see a damn thing unless you change it."
  247.                 say ""
  248.                 say "Press any key to continue..."
  249.                 junk=SysGetKey('noecho')
  250.             end    
  251.         end
  252.     end
  253.     do until fok=1
  254.         call SysCls
  255.         if fok=0 then do
  256.             call SysCurPos 4,0
  257.             say cstring
  258.         end
  259.         call SysCurPos 6,0
  260.         say "Choose the file window background color from the list,"||crlf||,
  261.             "or press S to skip this choice and use the default:"
  262.         call charout ,table
  263.         ans=SysGetKey('echo')
  264.         if translate(ans)='S' then do
  265.             FileColor='CYAN'
  266.             fok=1
  267.         end
  268.         else if datatype(ans)\='NUM' then fok=0
  269.         else if datatype(ans,'W')\=1 then fok=0
  270.         else if ans<1 | ans>8 then fok=0
  271.         else do
  272.             fok=1
  273.             FileColor=ColorID(ans)
  274.         end
  275.     end
  276.     fok=''
  277.     do until fok=1
  278.         call SysCls
  279.         if fok=0 then do
  280.             call SysCurPos 4,0
  281.             say cstring
  282.         end
  283.         call SysCurPos 6,0
  284.         say "Choose the file window text color from the list,"||crlf||,
  285.             "or press S to skip this choice and use the default:"
  286.         call charout ,table
  287.         ans=SysGetKey('echo')
  288.         if translate(ans)='S' then do
  289.             FileTextColor='BLACK'
  290.             fok=1
  291.         end
  292.         else if datatype(ans)\='NUM' then fok=0
  293.         else if datatype(ans,'W')\=1 then fok=0
  294.         else if ans<1 | ans>8 then fok=0
  295.         else do 
  296.             fok=1
  297.             FileTextColor=ColorID(ans)
  298.             if FileTextColor=FileColor then do
  299.                 say crlf    
  300.                 say "Note:  You have chosen the same color for both the"
  301.                 say "foreground and background of the File window.  You"
  302.                 say "won't be able to see a damn thing unless you change it."
  303.                 say ""
  304.                 say "Press any key to continue..."
  305.                 junk=SysGetKey('noecho')
  306.             end        
  307.         end
  308.     end
  309.     do until gok=1
  310.         call SysCls
  311.         if gok=0 then do
  312.             call SysCurPos 4,0
  313.             say cstring
  314.         end
  315.         call SysCurPos 6,0
  316.         say "Choose the graph window background color from the list,"||crlf||,
  317.             "or press S to skip this choice and use the default:"
  318.         call charout ,table
  319.         ans=SysGetKey('echo')
  320.         if translate(ans)='S' then do
  321.             GraphColor='BLACK'
  322.             gok=1
  323.         end
  324.         else if datatype(ans)\='NUM' then gok=0
  325.         else if datatype(ans,'W')\=1 then gok=0
  326.         else if ans<1 | ans>8 then gok=0
  327.         else do
  328.             gok=1
  329.             GraphColor=ColorID(ans)
  330.         end
  331.     end
  332.     gok=''
  333.     do until gok=1
  334.         call SysCls
  335.         if gok=0 then do
  336.             call SysCurPos 4,0
  337.             say cstring
  338.         end
  339.         call SysCurPos 6,0
  340.         say "Choose the graph window text color from the list,"||crlf||,
  341.             "or press S to skip this choice and use the default:"
  342.         call charout ,table
  343.         ans=SysGetKey('echo')
  344.         if translate(ans)='S' then do
  345.             GraphTextColor='WHITE'
  346.             gok=1
  347.         end
  348.         else if datatype(ans)\='NUM' then gok=0
  349.         else if datatype(ans,'W')\=1 then gok=0
  350.         else if ans<1 | ans>8 then gok=0
  351.         else do
  352.             gok=1
  353.             GraphTextColor=ColorID(ans)
  354.             if GraphTextColor=GraphColor then do
  355.                 say crlf
  356.                 say "Note:  You have chosen the same color for both the"
  357.                 say "foreground and background of the Graph window.  You"
  358.                 say "won't be able to see a damn thing unless you change it."
  359.                 say ""
  360.                 say "Press any key to continue..."
  361.                 junk=SysGetKey('noecho')
  362.             end        
  363.         end
  364.     end
  365.     do until freeok=1
  366.         call SysCls
  367.         if freeok=0 then do
  368.             call SysCurPos 4,0
  369.             say cstring
  370.         end
  371.         call SysCurPos 6,0
  372.         say "Choose the graph free space color from the list,"||crlf||,
  373.             "or press S to skip this choice and use the default:"
  374.         call charout ,table
  375.         ans=SysGetKey('echo')
  376.         if translate(ans)='S' then do
  377.             FreeColor='WHITE'
  378.             freeok=1
  379.         end
  380.         else if datatype(ans)\='NUM' then freeok=0
  381.         else if datatype(ans,'W')\=1 then freeok=0
  382.         else if ans<1 | ans>8 then freeok=0
  383.         else do
  384.             freeok=1
  385.             FreeColor=ColorID(ans)
  386.         end        
  387.     end
  388.     do until usedok=1
  389.         call SysCls
  390.         if usedok=0 then do
  391.             call SysCurPos 4,0
  392.             say cstring
  393.         end
  394.         call SysCurPos 6,0
  395.         say "Choose the graph used space color from the list,"||crlf||,
  396.             "or press S to skip this choice and use the default:"
  397.         call charout ,table
  398.         ans=SysGetKey('echo')
  399.         if translate(ans)='S' then do
  400.             UsedColor='GREEN'
  401.             usedok=1
  402.         end
  403.         else if datatype(ans)\='NUM' then usedok=0
  404.         else if datatype(ans,'W')\=1 then usedok=0
  405.         else if ans<1 | ans>8 then usedok=0
  406.         else do
  407.             usedok=1
  408.             UsedColor=ColorID(ans)
  409.         end        
  410.     end
  411.     do until wasteok=1
  412.         call SysCls
  413.         if wasteok=0 then do
  414.             call SysCurPos 4,0
  415.             say cstring
  416.         end
  417.         call SysCurPos 6,0
  418.         say "Choose the graph wasted space color from the list,"||crlf||,
  419.             "or press S to skip this choice and use the default:"
  420.         call charout ,table
  421.         ans=SysGetKey('echo')
  422.         if translate(ans)='S' then do
  423.             WasteColor='RED'
  424.             wasteok=1
  425.         end
  426.         else if datatype(ans)\='NUM' then wasteok=0
  427.         else if datatype(ans,'W')\=1 then wasteok=0
  428.         else if ans<1 | ans>8 then wasteok=0
  429.         else do
  430.             wasteok=1
  431.             WasteColor=ColorID(ans)
  432.         end        
  433.     end
  434.     if FreeColor=UsedColor | FreeColor=WasteColor |,
  435.         WasteColor=UsedColor then do
  436.             say crlf
  437.             say "Warning:  One or more graph colors are the same, and will"
  438.             say "inhibit the usefulness of the graph.  You should change"
  439.             say "them to different colors."
  440.             say ""
  441.             say "Press any key to continue..."
  442.             junk=SysGetKey('noecho')
  443.     end
  444.     inifile='drivechk.ini'
  445.     call SysFileDelete inifile
  446.     call lineout inifile,MainColor
  447.     call lineout inifile,MainTextColor
  448.     call lineout inifile,DirColor
  449.     call lineout inifile,DirTextColor
  450.     call lineout inifile,FileColor
  451.     call lineout inifile,FileTextColor
  452.     call lineout inifile,GraphColor
  453.     call lineout inifile,GraphTextColor
  454.     call lineout inifile,FreeColor
  455.     call lineout inifile,UsedColor
  456.     call lineout inifile,WasteColor
  457.     call lineout inifile,ScrRes     
  458.     do 5
  459.         call lineout inifile,''
  460.     end
  461.     call charout inifile,'Line 1: Background color of main window.'crlf
  462.     call charout inifile,'Line 2: Foreground color of main window.'crlf
  463.     call charout inifile,'Line 3: Background color of directory window.'crlf
  464.     call charout inifile,'Line 4: Foreground color of directory window.'crlf
  465.     call charout inifile,'Line 5: Background color of file window.'crlf
  466.     call charout inifile,'Line 6: Foreground color of file window.'crlf
  467.     call charout inifile,'Line 7: Background color of graph window.'crlf
  468.     call charout inifile,'Line 8: Foreground color of graph window.'crlf
  469.     call charout inifile,'Line 9: Free space color of graphs.'crlf
  470.     call charout inifile,'Line 10: Used space color of graphs.'crlf
  471.     call charout inifile,'Line 11: Wasted space color of graphs.'crlf
  472.     call charout inifile,'Line 12: Screen resolution.'crlf
  473.     call SysCls
  474.     call SysCurPos 12,0
  475.     say "INI file written ("||instdir||"\drivechk.ini)."
  476.     say ""
  477.     say "Press any key to continue..."
  478.     junk=SysGetKey('noecho')
  479. end
  480. if inionly=1 then exit
  481.  
  482. objmake:
  483. if objonly=1 then do
  484.     call SysCls
  485.     call SysCurPos 12,0
  486.     say "Please enter the directory where DriveCheck is located."
  487.     call charout ,': '
  488.     pull instdir
  489.     if directory(instdir)='' then do
  490.         say ""
  491.         say "Directory not found."
  492.         exit
  493.     end
  494. end        
  495.  
  496. call SysCls
  497. call SysCurPos 6,0
  498. say "We will now create a desktop object for DriveCheck.  If you don't"
  499. say "plan on using the Visual REXX portion, you're better off skipping"
  500. say "this and just running DriveCheck from the command line."
  501. say ""
  502. say "The object will be located at the center of your desktop, and its"
  503. say "object ID will be '<DriveCheck>' (case sensitive)."
  504. say ""
  505. say "Press Q to abort object creation, or any other key to continue..."
  506. ans=SysGetKey('noecho')
  507. if translate(ans)='Q' then skipobj=1
  508. else skipobj=0
  509. if skipobj=0 then do
  510.      type='WPProgram'
  511.      name='DriveCheck'
  512.      loc='<WP_DESKTOP>'
  513.      options='OBJECTID=<DriveCheck>;'                           ||,
  514.              'ICONPOS=50,50;'                                   ||,
  515.              'EXENAME='||instdir||'\drivechk.cmd;'              ||,
  516.              'ICONFILE='||instdir||'\drivechk.ico;'             ||,
  517.              'MINIMIZED=YES;'                                   ||,
  518.              'PROGTYPE=WINDOWABLEVIO'
  519.  
  520. rc=SysCreateObject(type,name,loc,options,'R')
  521. say ""
  522. if rc=1 then say "DriveCheck object successfully created."
  523. else say "Unable to create DriveCheck object."
  524. say ""
  525. if objonly=1 then exit
  526. end
  527. say ""
  528. say "DriveCheck installation is complete."
  529. exit
  530.  
  531. usage:
  532.  
  533. say ""
  534. say "DriveCheck installation program."
  535. say ""
  536. say "Usage: install.cmd [/I | /O]"
  537. say ""
  538. say "/I   -  Only prompts for information to create INI file."
  539. say "/O   -  Only creates desktop object."
  540. say ""
  541. say "Run with no parameters to copy the DriveCheck files to a specified"
  542. say "directory, create an INI file, and create a desktop object."
  543. say ""
  544.  
  545.  
  546. /* Translate number into color */
  547. ColorID: Procedure
  548.  
  549. arg cnum
  550. if cnum=1 then cr='BLACK'
  551. if cnum=2 then cr='WHITE'
  552. if cnum=3 then cr='RED'
  553. if cnum=4 then cr='GREEN'
  554. if cnum=5 then cr='BLUE'
  555. if cnum=6 then cr='CYAN'
  556. if cnum=7 then cr='YELLOW'
  557. if cnum=8 then cr='PINK'
  558.  
  559. return cr
  560. /**/
  561.  
  562. /* Translate number into resolution */
  563. ResID: Procedure
  564.  
  565. arg rnum
  566. if rnum=1 then res='640x480'
  567. if rnum=2 then res='800x600'
  568. if rnum=3 then res='1024x768'
  569. if rnum=4 then res='1280x1024'
  570. if rnum=5 then res='1600x1200'
  571.  
  572. return res
  573. /**/
  574.